<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title> Insha - Css3 Responsive Sidebar Menu</title>

    <link href="static/css/css2.css" rel="stylesheet">
    <link href='static/css/boxicons.min.css' rel='stylesheet'>
    <link rel="stylesheet" href="static/css/insha-style.css">

</head>
<body>

<div class="main" id="app">
    <div class="sidebar">
        <div class="logo_content">
            <div class="logo">
                <div class="logo_name">
                    <a href="#">
                        <i class='bx bxs-bank'></i>
                        银行业务管理系统
                    </a>
                </div>
            </div>
            <i class='bx bx-menu' id="toggle-menu-btn"></i>
        </div>
        <ul class="nav_list">
            <li>
                <a href="online.html">
                    <i class='bx bx-yen'></i>
                    <span class="links_name">网上银行</span>
                </a>
                <span class="tooltip">网上银行</span>
            </li>
            <li>
                <a href="counter.html">
                    <i class='bx bxs-user-account'></i>
                    <span class="links_name">银行柜面</span>
                </a>
                <span class="tooltip">银行柜面</span>
            </li>
        </ul>
    </div>
    <div class="home_content">
        <div class="text">网上银行</div>
        <div class="rg_layout">
            <div class="rg_left">
                <p>用户登录</p>
                <p>LOGIN</p>

            </div>
            <div class="rg_center">
                <div class="rg_form">
                    <!--定义表单 form-->
                    <form action="#" method="">
                        <table id="tbe1">
                            <tr>
                                <td class="td_left"><label for="phone">手机号</label></td>
                                <td class="td_right"><input type="text" name="phone" id="phone"
                                                            placeholder="手机号为11位" v-model="phone" @blur="ph()">
                                </td>
                                <td>
                                    <button @click="btu()">获取验证码</button>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_left"><label for="verificationCode">短信验证码</label></td>
                                <td class="td_right"><input type="text" name="verificationCode" id="verificationCode"
                                                            placeholder="请输入验证码" v-model="vCode" @blur="vc()">
                                </td>
                            </tr>


                            <tr>
                                <td colspan="2" align="center"><input type="button" id="btn_sub" value="确认登录"
                                                                      @click="cm()"></td>
                            </tr>
                        </table>

                    </form>


                </div>
            </div>
            <div class="rg_right">
                <p>使用身份证号+密码方式登录<a href="online copy.html">切换登录方式</a></p>
            </div>
        </div>
    </div>
</div>

<script src="static/js/scripts.js"></script>
<script src="static/js/vue.js"></script>
<script src="static/js/axios.min.js"></script>
<script src="static/js/qs.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/qs/6.11.0/qs.js"></script>
<script>
    const app = new Vue({
        el: "#app",
        data: {

            phone: "",
            vCode: null

        },
        methods: {

            ph() {
                let rule = new RegExp("(^\\d{11}$)")
                if (rule.test(this.phone) === false) {
                    alert("您的手机号码格式不正确")
                    this.phone = "";
                }
            },
            btu() {
                let param = {phone: this.phone}
                axios({
                    method: "post",
                    url: "http://localhost:8080/user/getCode",
                    data: Qs.stringify(param)
                }).then(res => {
                    if (res.data.code == 500) {
                        alert(res.data.msg)
                    } else {
                        //此处获取验证码
                        alert("您的验证码为:" + res.data.data)
                    }
                })
            },
            cm() {
                if (this.phone == "" || this.vCode == null) {
                    alert("上述信息请勿为空")
                } else {
                    localStorage.setItem("phone", this.phone)
                    //此处修改验证码参数
                    axios.post("http://localhost:8080/user/login", {
                        username: this.phone,
                        password: this.vCode,
                        type: 0
                    }).then(res => {
                        let msg = res.data.message;
                        let code = res.data.code;
                        if (code == 500) {
                            alert(msg);
                        } else if (code == 201) {
                            alert(msg)
                        } else if (code == 222) {
                            //此处为判断是否有登陆密码
                            location.href = "setpassword.html"
                        } else {
                            var bankNo = res.data.data.bankNo
                            localStorage.setItem("bankNo", bankNo)
                            location.href = "onlineindex.html"
                        }
                    })
                }
            }


        }
    })
</script>

</body>
</html>
